package com.woniuxy.third.config;

import com.woniuxy.third.filter.CrossFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean<CrossFilter> corssFilterFilterRegistrationBean(){
        FilterRegistrationBean bean = new FilterRegistrationBean();
        //设置过滤器
        bean.setFilter(new CrossFilter());
        //设置urlpattern
        List<String> patterns = new ArrayList<>();
        patterns.add("/*");
        bean.setUrlPatterns(patterns);
        //设置执行顺序
        bean.setOrder(0);
        return bean;
    }
}
